package com.gitee.ywj1352.common;

import com.gitee.ywj1352.common.message.ClientOp;
import com.gitee.ywj1352.common.message.RequestMessage;
import io.netty.channel.ChannelHandlerContext;
import io.netty.handler.codec.MessageToMessageEncoder;

import java.util.List;

public class OperationToRequestMessageEncoder extends MessageToMessageEncoder<ClientOp> {
    @Override
    protected void encode(ChannelHandlerContext ctx, ClientOp operation, List<Object> out) throws Exception {
        RequestMessage requestMessage = operation.getClientStructure().generateRequestMessage(operation.getMethodName(), operation.getParams());
        out.add(requestMessage);
    }
}
